package com.atmk.atmk.designMode.创建型.工厂模式.应用实例.简单工厂;

import java.util.Calendar;
import java.util.TimeZone;

//JDK 中的Calendar类中，就使用了简单工厂模式
public class CalendarTest {
    public static void main(String[] args) {
        TimeZone usTimeZone = TimeZone.getTimeZone("123"); // 以纽约的东部时间为例
        Calendar cal = Calendar.getInstance(usTimeZone);
        Calendar.getInstance();
        // 注意月份下标从0开始，所以取月份要+1
        System.out.println("年:"+ cal.get(Calendar.YEAR));
        System.out.println("月:"+ (cal.get(Calendar.MONTH) + 1));
        System.out.println("日:"+ cal.get(Calendar.DAY_OF_MONTH));
        System.out.println("时:"+ cal.get(Calendar.HOUR_OF_DAY));
        System.out.println("分:"+ cal.get(Calendar.MINUTE));
        System.out.println("秒:"+ cal.get(Calendar.SECOND));
    }
}
